<template>
  <div class="home">
    <div class="banner">
      <div class="banxin">
        <img src="../assets/images/home/banner.png" alt="" />
      </div>
    </div>
    <Title :src="Recommend" title="精品推荐" />
    <Products :arr="records" />
    <Title :src="hot" title="热门兑换" />
    <img
      class="banxin"
      src="../assets/images/home/ad.png"
      alt=""
      style="display: block; margin-bottom: 20px"
    />
    <Products :arr="hotArr" />
    <Title :src="integral" title="积分攻略" />
    <ul class="jifen banxin">
      <li :style="{ backgroundImage: `url(${jifenImg1})` }">
        <h3>签到得鸡腿</h3>
        <div>去签到</div>
      </li>
      <li :style="{ backgroundImage: `url(${jifenImg2})` }">
        <h3>购课得鸡腿</h3>
        <div>去购课</div>
      </li>
      <li :style="{ backgroundImage: `url(${jifenImg3})` }">
        <h3>推荐得鸡腿</h3>
        <div>去推荐</div>
      </li>
      <li :style="{ backgroundImage: `url(${jifenImg4})` }">
        <h3>做任务得鸡腿</h3>
        <div>做任务</div>
      </li>
    </ul>
  </div>
</template>

<script>
import { JingpinApi, HotApi } from "@/request/api.js";
import Title from "@/components/home/Title.vue";
import Products from "@/components/Products.vue";

export default {
  data() {
    return {
      jifenImg1: require("../assets/images/home/integral-01.png"),
      jifenImg2: require("../assets/images/home/integral-02.png"),
      jifenImg3: require("../assets/images/home/integral-03.png"),
      jifenImg4: require("../assets/images/home/integral-04.png"),

      Recommend: require("../assets/images/home/Recommend.png"),
      hot: require("../assets/images/home/hot.png"),
      integral: require("../assets/images/home/integral.png"),
      // Jingpin:''
      // 精品推荐数组
      records: [],
      //  热门
      hotArr: [],
    };
  },
  components: {
    Title,
    Products,
  },

  created() {
    JingpinApi().then((res) => {
      if (res.data.code === 0) {
        // console.log(res.data.data.data.records);//这里输出的
        this.records = res.data.data.data.records;
        //     // 一般拿到数据吼不动数据源
        //     let myarr=JSON.parse(JSON.stringify(res.data.data.data.records));
        //     // 去掉最后一个
        //    myarr.pop();
        // //    赋值
        //     this. jingpinArr=myarr;
      }
    });

    HotApi().then((res) => {
      if (res.data.code === 0) {
        console.log(res.data.data.data.records);
        this.hotArr = res.data.data.data.records;
      }
    });
  },
};
</script>

<style lang = "less" scoped>
@import "../assets/base.less";
.banner {
  width: 100%;
  background-color: #fff;
  padding-bottom: 30px;
  img {
    display: block;
  }
}
.jifen {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  li {
    width: 285px;
    height: 168px;
    color: #fff;
    padding: 20px 10px;
    box-sizing: border-box;
    cursor: pointer;
    transition: background-size 0.5s linear;
    background-size: 100% 100%;
    &:hover {
      background-size: 110% 110%;
    }
    h3 {
      font-size: 24px;
      margin-bottom: 19px;
    }
    div {
      width: 96px;
      height: 27px;
      border: 1px solid #fff;
      text-align: center;
      line-height: 27px;
    }
  }
}
</style>  